﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace GameTank
{
    public class GamePlayMenu : Form
    {
        protected TextMenuComponent menu;
        protected readonly Texture2D elements;
        protected Texture2D _background;
        private Rectangle _menuScene = new Rectangle (100,100,352,480);

        protected Rectangle MenuSceneBounder
        {
            get { return _menuScene; }
            set { _menuScene = value; }
        }

        // Audio
        protected AudioLibrary audio;
        // Spritebatch
        public GamePlayMenu(SpriteFont smallFont, SpriteFont largeFont,
                            Texture2D background)            
        {
            _background = background;

            // Create the Menu
            string[] items = { "Resume mission /ESC", "Restart game","Quick save","Quick load", "Quit Mission" };
            menu = new TextMenuComponent( smallFont, largeFont);
            menu.SetMenuItems(items);
            Childs.Add(menu);

            // Get the current spritebatch
          
            // Get the audio library
            audio = Game1.AudioLib;
        }

        /// <summary>
        /// Show the start scene
        /// </summary>
        public override void Show()
        {
            //audio.NewMeteor.Play();
            // Put the menu centered in screen
            menu.Position = new Vector2( MenuSceneBounder.X+20,MenuSceneBounder.Y+50);

            // These elements will be visible when the 'Rock Rain' title
            // is done.
            menu.Visible = true;
            menu.Enable = true;
            menu.SelectedIndex = 0;
            //MediaPlayer.Play(audio.StartMusic);
            base.Show();
        }

        public override void Hide()
        {
            menu.Visible = false;
            menu.Enable = false;
            //MediaPlayer.Stop();
            base.Hide();
        }

        /// <summary>
        /// Gets the selected menu option
        /// </summary>
        public int SelectedMenuIndex
        {
            get { return menu.SelectedIndex; }
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            menu.Visible = true;
            menu.Enable = true;
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(_background,MenuSceneBounder,Color.White);
            spriteBatch.End();
            base.Draw(gameTime,spriteBatch);
        }
    }
}
